#include "comm.hpp"

int main()
{
    createFifo(NAMED_PIPE);

    int rfd = open(NAMED_PIPE,O_RDONLY);
    if(rfd < 0)exit(1);

    while(true)
    {
        char buffer[1024];
        ssize_t s = read(rfd,buffer,sizeof(buffer));
        if(s > 0)
        {
            buffer[s] = 0;
            std::cout << "client->server#" << buffer << std::endl;
        }
        else if(s == 0)
        {
            std::cout << "client quie,me too!" << std::endl;
            break;
        }
        else
        {
            std::cout << "err string" << strerror(errno) << std::endl; 
            break;
        }
    }
    close(rfd);

    removeFifo(NAMED_PIPE);

    return 0;
}